<?php
/**
 * As of version 5.2.5, PHP is not able to garbage collect object graphs that have circular references, 
 * e.g. Parent has a reference to Child which has a reference to Parent.
 * PHP will not free objects memory even when the objects go out of scope.
 */
class Tedi_Memory
{
	public static function free($variable)
	{
        // version 5.3 has better garbage collector than 5.2 so free objects is not necessary
		if(Tedi_PHP::getVersion() < 5.3)
		{
			if(is_object($variable))
			{
				foreach(array('free', 'shutdown') as $method)
				{
					if(method_exists($variable, $method))
					{
						call_user_method($method, $variable);
						break;
					}
				}
			}	
		}
		
		unset($variable);
	}
	

}